home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / lib / openoffice / program / soffice < prev    next >
Text File  |  2008-10-15  |  10KB  |  395 lines

  1. #!/bin/sh
  2. #*************************************************************************
  3. #
  4. #   OpenOffice.org - a multi-platform office productivity suite
  5. #
  6. #   $RCSfile: soffice.sh,v $
  7. #
  8. #   $Revision: 1.28.48.1 $
  9. #
  10. #   last change: $Author: hr $ $Date: 2008/01/02 14:47:34 $
  11. #
  12. #   The Contents of this file are made available subject to
  13. #   the terms of GNU Lesser General Public License Version 2.1.
  14. #
  15. #
  16. #     GNU Lesser General Public License Version 2.1
  17. #     =============================================
  18. #     Copyright 2005 by Sun Microsystems, Inc.
  19. #     901 San Antonio Road, Palo Alto, CA 94303, USA
  20. #
  21. #     This library is free software; you can redistribute it and/or
  22. #     modify it under the terms of the GNU Lesser General Public
  23. #     License version 2.1, as published by the Free Software Foundation.
  24. #
  25. #     This library is distributed in the hope that it will be useful,
  26. #     but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28. #     Lesser General Public License for more details.
  29. #
  30. #     You should have received a copy of the GNU Lesser General Public
  31. #     License along with this library; if not, write to the Free Software
  32. #     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33. #     MA  02111-1307  USA
  34. #
  35. #*************************************************************************
  36.  
  37. #
  38. # STAR_PROFILE_LOCKING_DISABLED=1
  39. # export STAR_PROFILE_LOCKING_DISABLED
  40. #
  41.  
  42. if test -z "$HOME"; then
  43.     HOME=$(getent passwd $(whoami) | cut -d":" -f6)
  44. fi
  45.  
  46. # Ubuntu helper functions
  47. file_or_home_on_nfs()
  48. {
  49.     case $(stat -f -c %T $HOME) in nfs*|smb)
  50.         return 0
  51.     esac
  52.     for i; do
  53.        case "$i" in -*) continue; esac
  54.        [ -f "$i" ] || continue
  55.        case $(stat -f -c %T "$i") in nfs*|smb)
  56.             return 0
  57.        esac
  58.     done
  59.     return 1
  60. }
  61.  
  62. # FIXME: this is conservative; allow more known working configurations
  63. working_opengl_support()
  64. {
  65.     if [ -n "$(lsmod | awk '/^(fglrx|nvidia)/ {print $1}')" ]; then
  66.     return 1
  67.     fi
  68.     return 0
  69. }
  70.  
  71. # read Ubuntu config file
  72.  
  73. FILE_LOCKING=auto
  74. OPENGL_SUPPORT=no
  75. if [ -f /etc/openoffice/soffice.sh ]; then
  76.     . /etc/openoffice/soffice.sh
  77. fi
  78.  
  79. # sanity checks
  80.  
  81. case "$FILE_LOCKING" in
  82.     auto|yes|no) ;;
  83.     *)
  84.         echo >&2 "unknown value '$FILE_LOCKING' for FILE_LOCKING parameter."
  85.     FILE_LOCKING=auto
  86.     echo >&2 "FILE_LOCKING reset to '$FILE_LOCKING'"
  87. esac
  88.     
  89. case "$OPENGL_SUPPORT" in
  90.     auto|yes|no) ;;
  91.     *)
  92.         echo >&2 "unknown value '$OPENGL_SUPPORT' for OPENGL_SUPPORT parameter."
  93.     OPENGL_SUPPORT=auto
  94.     echo >&2 "OPENGL_SUPPORT reset to '$OPENGL_SUPPORT'"
  95. esac
  96.  
  97. # adjust environment
  98.  
  99. if [ -z "$SAL_ENABLE_FILE_LOCKING" ]; then
  100.     case "$FILE_LOCKING" in
  101.     auto)
  102.         file_or_home_on_nfs "$@"
  103.         if [ $? -eq 0 ]; then
  104.             # file locking now enabled by default
  105.         SAL_ENABLE_FILE_LOCKING=1
  106.         export SAL_ENABLE_FILE_LOCKING
  107.     fi
  108.         ;;
  109.     yes)
  110.     SAL_ENABLE_FILE_LOCKING=1
  111.     export SAL_ENABLE_FILE_LOCKING
  112.         ;;
  113.     no)
  114.     SAL_ENABLE_FILE_LOCKING=0
  115.     export SAL_ENABLE_FILE_LOCKING
  116.     esac
  117. fi
  118.  
  119. if [ -z "$SAL_NOOPENGL" ]; then
  120.     case "$OPENGL_SUPPORT" in
  121.     auto)
  122.         working_opengl_support
  123.         if [ $? -eq 0 ]; then
  124.         SAL_NOOPENGL=true
  125.         export SAL_NOOPENGL
  126.     fi
  127.         ;;
  128.     yes)
  129.     :
  130.     unset SAL_NOOPENGL
  131.     #export SAL_NOOPENGL
  132.         ;;
  133.     no)
  134.     SAL_NOOPENGL=true
  135.     export SAL_NOOPENGL
  136.     esac
  137. fi
  138.  
  139. sd_platform=`uname -s`
  140.  
  141. # the following test is needed on Linux PPC with IBM j2sdk142
  142. if [ $sd_platform = "Linux" -a "`uname -m`" = "ppc" ] ; then
  143.     JITC_PROCESSOR_TYPE=6
  144.     export JITC_PROCESSOR_TYPE
  145. fi
  146.  
  147. # set -x
  148.  
  149. # resolve installation directory
  150. sd_cwd="`pwd`"
  151. if [ -h "$0" ] ; then
  152.     sd_basename=`basename "$0"`
  153.      sd_script=`ls -l "$0" | sed "s/.*${sd_basename} -> //g"`
  154.     cd "`dirname "$0"`"
  155.     cd "`dirname "$sd_script"`"
  156. else
  157.     cd "`dirname "$0"`"
  158. fi
  159.  
  160. sd_prog="`pwd`"
  161.  
  162. cd ..
  163. sd_binary=`basename "$0"`".bin"
  164. sd_inst="`pwd`"
  165.  
  166. # change back directory
  167. cd "$sd_cwd"
  168.  
  169. # check if all required patches are installed
  170. if [ -x "$sd_prog/sopatchlevel.sh" ]; then
  171.     "$sd_prog/sopatchlevel.sh"
  172.     if [ $? -eq 1 ]; then
  173.         exit 0
  174.     fi
  175. fi
  176.  
  177. # set search path for shared libraries
  178. add_moz_lib=
  179. for moz_lib_path in \
  180.     $MOZILLA_LIBRARY_PATH \
  181.     /usr/lib \
  182.     /usr/lib/mozilla \
  183.     /usr/lib/mozilla-firefox \
  184.     /usr/lib/mozilla-thunderbird \
  185.     /opt/mozilla/lib \
  186.     /opt/MozillaFirefox/lib \
  187.     /opt/MozillaThunderbird/lib; \
  188. do
  189.     if [ -f $moz_lib_path/libnss3.so ]; then
  190.     case "$moz_lib_path" in
  191.         /usr/lib|/usr/lib64) : ;;
  192.         *) add_moz_lib=":$moz_lib_path"
  193.     esac
  194.     break
  195.     fi
  196. done
  197. case $sd_platform in
  198.   AIX)
  199.     # this is a temporary hack until we can live with the default search paths
  200.     if [ $LIBPATH ]; then
  201.       SYSTEM_LIBPATH=$LIBPATH
  202.       export SYSTEM_LIBPATH
  203.       LIBPATH="$sd_prog$add_moz_lib":$LIBPATH
  204.     else
  205.       LIBPATH="$sd_prog$add_moz_lib"
  206.     fi
  207.     export LIBPATH
  208.     ;;
  209.  
  210.   Darwin)
  211.     # this is a temporary hack until we can live with the default search paths
  212.     if [ "$DYLD_LIBRARY_PATH" ]; then
  213.       SYSTEM_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
  214.       export SYSTEM_DYLD_LIBRARY_PATH
  215.       DYLD_LIBRARY_PATH="$sd_prog$add_moz_lib":$DYLD_LIBRARY_PATH
  216.     else
  217.       DYLD_LIBRARY_PATH="$sd_prog$add_moz_lib"
  218.     fi
  219.     export DYLD_LIBRARY_PATH
  220.     ;;
  221.  
  222.   HP-UX)
  223.     # this is a temporary hack until we can live with the default search paths
  224.     if [ $SHLIB_PATH ]; then
  225.       SYSTEM_SHLIB_PATH=$SHLIB_PATH
  226.       export SYSTEM_SHLIB_PATH
  227.       SHLIB_PATH="$sd_prog$add_moz_lib":/usr/openwin/lib:$SHLIB_PATH
  228.     else
  229.       SHLIB_PATH="$sd_prog$add_moz_lib":/usr/openwin/lib
  230.     fi
  231.     export SHLIB_PATH
  232.     ;;
  233.  
  234.   IRIX*)
  235.     # this is a temporary hack until we can live with the default search paths
  236.     if [ $LD_LIBRARYN32_PATH ]; then
  237.        SYSTEM_LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH
  238.        export SYSTEM_LD_LIBRARYN32_PATH
  239.        LD_LIBRARYN32_PATH=:"$sd_prog$add_moz_lib":$LD_LIBRARYN32_PATH
  240.     else
  241.        LD_LIBRARYN32_PATH=:"$sd_prog$add_moz_lib"
  242.     fi
  243.     export LD_LIBRARYN32_PATH
  244.     ;;
  245.  
  246.   *)
  247.     # this is a temporary hack until we can live with the default search paths
  248.     if [ $LD_LIBRARY_PATH ]; then
  249.       SYSTEM_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
  250.       export SYSTEM_LD_LIBRARY_PATH
  251.       LD_LIBRARY_PATH="$sd_prog$add_moz_lib":$LD_LIBRARY_PATH
  252.     else
  253.       LD_LIBRARY_PATH="$sd_prog$add_moz_lib"
  254.     fi
  255.     export LD_LIBRARY_PATH
  256.     ;;
  257. esac
  258.  
  259. #collect all bootstrap variables specified on the command line
  260. #so that they can be passed as arguments to javaldx later on
  261. for arg in $@
  262. do
  263.   case "$arg" in
  264.        -env:*) BOOTSTRAPVARS=$BOOTSTRAPVARS" ""$arg";;
  265.   esac
  266. done
  267.  
  268. # extend the ld_library_path for java: javaldx checks the sofficerc for us
  269. unset java_ld_library_path
  270. if [ -x "$sd_prog/javaldx" ] ; then
  271.     java_ld_library_path=`"$sd_prog/javaldx" $BOOTSTRAPVARS`
  272. elif [ -x "$sd_prog/../ure-link/javaldx" ] ; then
  273.     java_ld_library_path=`"$sd_prog/../ure-link/javaldx" $BOOTSTRAPVARS`
  274. fi
  275. if [ "$java_ld_library_path" != "" ] ; then
  276.     case $sd_platform in
  277.         AIX)
  278.             LIBPATH=${java_ld_library_path}:${LIBPATH}
  279.             ;;
  280.         Darwin)
  281.             DYLD_LIBRARY_PATH=${java_ld_library_path}:${DYLD_LIBRARY_PATH}
  282.             ;;
  283.         HP-UX)
  284.             SHLIB_PATH=${java_ld_library_path}:${SHLIB_PATH}
  285.             ;;
  286.         IRIX*)
  287.             LD_LIBRARYN32_PATH=${java_ld_library_path}:${LD_LIBRARYN32_PATH}
  288.             ;;
  289.         *)
  290.             LD_LIBRARY_PATH=${java_ld_library_path}:${LD_LIBRARY_PATH}
  291.             ;;
  292.     esac
  293. fi
  294.  
  295. # misc. environment variables
  296. OPENOFFICE_MOZILLA_FIVE_HOME="$sd_inst/program"
  297. export OPENOFFICE_MOZILLA_FIVE_HOME
  298.  
  299. if [ -z "$MOZILLA_CERTIFICATE_FOLDER" ]; then
  300.     db=""
  301.     dir=""
  302.     for d in $HOME/.mozilla/firefox $HOME/.firefox $HOME/.mozilla-thunderbird $HOME/.mozilla/default $HOME/.mozilla; do
  303.         if [ -z "$dir" -a -d "$d" ]; then
  304.             dir=$d;
  305.         fi;
  306.     done
  307.     if [ -n "$dir" ]; then
  308.         # In most case cert8.db will be in $dir/*/cert8.db.
  309.             # Test this first. Do a full search otherwise.
  310.         cert8=`find $dir -maxdepth 2 -name "cert8.db" | head -n 1`
  311.             if [ ! -n "$cert8" ]; then
  312.             cert8=`find $dir -name "cert8.db" | head -n 1`
  313.         fi
  314.         if [ -n "$cert8" ]; then
  315.             profiledir=`dirname "$cert8"`
  316.             MOZILLA_CERTIFICATE_FOLDER=$profiledir
  317.             export MOZILLA_CERTIFICATE_FOLDER
  318.         fi
  319.     fi
  320. fi
  321.  
  322. unset XENVIRONMENT
  323.  
  324. # uncomment line below to disable anti aliasing of fonts
  325. # SAL_ANTIALIAS_DISABLE=true; export SAL_ANTIALIAS_DISABLE
  326.  
  327. # pagein
  328. for sd_arg in ${1+"$@"} ; do
  329.     case ${sd_arg} in
  330.     -calc)
  331.         sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-calc"
  332.         break;
  333.         ;;
  334.     -draw)
  335.         sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-draw"
  336.         break;
  337.         ;;
  338.     -impress)
  339.         sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-impress"
  340.         break;
  341.         ;;
  342.     -writer)
  343.         sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-writer"
  344.         break;
  345.         ;;
  346.     *)
  347.         ;;
  348.     esac
  349. done
  350.  
  351. sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-common"
  352. "${sd_prog}"/pagein -L"${sd_prog}" ${sd_pagein_args}
  353.  
  354. # set path so that other apps can be started from soffice just by name
  355. if [ "$PATH" ]; then
  356.   PATH="$sd_prog":$PATH
  357. else
  358.   PATH="$sd_prog"
  359. fi
  360. export PATH
  361.  
  362. # test for availability of the fast external splash
  363. for arg in $@; do
  364.     if [ "$arg" = "-nologo" -o "$arg" = "-no-oosplash" ]; then
  365.         no_oosplash=y
  366.     fi
  367. done
  368. if [ "$sd_binary" = "soffice.bin" -a -x "$sd_prog/oosplash.bin" ] && [ "$no_oosplash" != "y" ] ; then
  369.     sd_binary="oosplash.bin"
  370. fi
  371.  
  372. # Fix for bug #mdv41228 #i89207
  373. # Remove this line:
  374. # <library:library library:name="WebWizard" xlink:href="file:///usr/lib/openoffice/share/basic/WebWizard/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="true"/>
  375. # from files below.
  376. # Since 2007.0 WebWizard does not exist anymore.
  377. dialog_xlc=~/.openoffice.org2/user/basic/dialog.xlc
  378. script_xlc=~/.openoffice.org2/user/basic/script.xlc
  379. if [ -f $dialog_xlc -a -f $script_xlc ]; then
  380.     sed -i "s/.*library:name=\"WebWizard\".*openoffice.*//" $dialog_xlc $script_xlc
  381. fi
  382.  
  383. # execute soffice binary
  384. "$sd_prog/$sd_binary" "$@" &
  385. trap 'kill -9 $!' TERM
  386. wait $!
  387.  
  388. while [ $? -eq 79 ]
  389. do
  390.     "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" &
  391.     wait $!
  392. done
  393.  
  394. exit
  395.